import Mutil from "util/mim.jsx";
const mm = new Mutil();

class User {
  login(logininfo) {
    return mm.request({
      type: "post",
      url: "/manage/user/login.do",
      data: logininfo
    });
  }
  //检测登录数据是否合法
  checkLoginInfo(logininfo) {
    let username = $.trim(logininfo.username);
    let password = $.trim(logininfo.password);
    //判断用户名
    if (typeof username !== "string" || username.length === 0) {
      return {
        status: false,
        msg: "用户名不为空"
      };
    }
    //判断密码
    if (typeof password !== "string" || password.length === 0) {
      return {
        status: false,
        msg: "密码不能为空"
      };
    }
    return {
      status: true,
      msg: "验证成功"
    };
  }
  //退出登录
  logout() {
    return mm.request({
      type: "post",
      url: "/user/logout.do"
    });
  }
  //获取用户
  getUserList(pageNum) {
    return mm.request({
      type: "post",
      url: "/manage/user/list.do",
      data: {
        pageNum: pageNum
      }
    });
  }
}
export default User;
